package IO_;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
    使用字符流读取文件
    Reader
 */
public class Io07 {
    public static void main1(String[] args) {
        try(Reader reader=new FileReader("./test.exe")){
            while(true){
                int n=reader.read();
                if(n==-1){
                    break;
                }
                System.out.printf("%c",n);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static void main(String[] args) {
        try(Reader reader=new FileReader("./test.exe")){
            while(true){
                char[] buffer=new char[1024];
                int n=reader.read(buffer);
                if(n==-1){
                    break;
                }
                String s=new String(buffer,0,n);
                System.out.println(s);
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
